package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddOperation implements IOPeration {
    public void work(BookList bookList) {
        if(bookList.getUseSize() >= bookList.getMaxSize()) {
            System.out.println("该书架已满，无法存下");
            return;
        }
        System.out.println("新增图书");
        Scanner in = new Scanner(System.in);
        System.out.println("请输入书的名字");
        String name = in.nextLine();
        System.out.println("请输入书的作者");
        String author = in.nextLine();
        System.out.println("请输入书的价格");
        double price = in.nextDouble();
        in.nextLine();
        System.out.println("请输入书的类型");
        String type = in.nextLine();
        Book book = new Book(name, author, price, type);
        bookList.setBook(bookList.getUseSize(), book);
        bookList.setUseSize(bookList.getUseSize() + 1);
    }
}
